#ifndef CUSTOMSCROLLVIEW_H
#define CUSTOMSCROLLVIEW_H

#include <QScrollArea>
#include <QPointer>

class CustomScrollViewThumb;

class CustomScrollView : public QScrollArea {
    Q_OBJECT
public:
    explicit CustomScrollView(QWidget *parent = nullptr);

    // 便捷方法：设置内容组件
    void setContentWidget(QWidget *widget);

protected:
    void resizeEvent(QResizeEvent *event) override;
    bool eventFilter(QObject *watched, QEvent *event) override;

private slots:
    void onVScrollChanged(int value);
    void onHScrollChanged(int value);

private:
    void initThumbs();
    void updateThumbsGeometry();
    int verticalTrackLength() const;
    int horizontalTrackLength() const;

    QPointer<CustomScrollViewThumb> m_vThumb;
    QPointer<CustomScrollViewThumb> m_hThumb;
};

#endif // CUSTOMSCROLLVIEW_H


